<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAttachmentTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create ('attachment', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('id')->primary ();
            $table->string ('file_name', 64);//文件名称
            $table->string ('local_path', 64);//本地图片地址
            $table->string ('remote_url', 100);//远程图片地址
            $table->char ('file_md5', 32);//图片MD5
            $table->char ('file_sha1', 40);//图片sha1
            $table->uuid ('user_id');//用户ID
            $table->integer ('file_size');//文件大小
            $table->tinyInteger ('file_type');//文件类型
            $table->foreign ('user_id')->references ('id')->on ('users')->onDelete ('cascade');//用户外键
            $table->timestamps ();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists ('attachment');
    }
}
